#if 1
/*
 * testCImg.cpp
 *
 *  Created on: 2016年1月16日
 *      Author: guyadong
 */
//#include "stdio.h"
#include <iostream>
#include <fstream>
#include <string>
#include <iostream>
#include "file_utilits.h"
#include "CImgWrapper.h"
#include "jpeg_mem_advance.h"
#include "j2k_mem_advance.h"
using namespace cimg_library;
// 类实例化，用于检查是否有编译错误
template class CImgWrapper<uint8_t>;
typedef CImgWrapper<uint8_t> CImgWrapperUChar;
//using namespace gdface;
using namespace std;
int main()
{
	try {
	 
		const char *input_jpg_file = "C:/Code/jpeg2k_wrap/src/images/jpeg.jpg";
	 
		const char *output4_jpg_file = "C:/Code/jpeg2k_wrap/src/images/jpeg-out4.jp2";
	 
		CImgWrapperUChar image_jpg;
		std::vector<uint8_t> jpeg_data=gdface::load_binary_file(input_jpg_file);
		 
		image_jpg.load_mem_jpeg(
				jpeg_data,
				[](j_common_ptr cinfo){
					((j_decompress_ptr)cinfo)->out_color_space=JCS_GRAYSCALE;
			});
		auto mat=load_jpeg_mem(jpeg_data.data(), jpeg_data.size(),[](j_common_ptr cinfo) {
			 
		});
	 
		auto output=save_j2k_mem(mat,45, OPJ_CODEC_JP2);
		gdface::save_binary_file(output4_jpg_file,output.stream_data(),size_t(output.stream_length()));
		 
		auto j2k_data=gdface::load_binary_file(output4_jpg_file);
		image_jpg.load_mem_j2k(j2k_data.data(), j2k_data.size(), FS_JPEG2K_CODEC_JP2);
	
	/*	image_jpg.display(output4_jpg_file);*/
		auto j2k_mat = jwp_load_j2k_mem(j2k_data.data(), j2k_data.size(), FS_JPEG2K_CODEC_JP2);
	/*	cimg_library::image_matrix_display(j2k_mat, "test jwp_load_j2k_mem display", true);*/

	}catch (exception &e){
		cout<<e.what()<<endl;
	}
	 
	return 0;
}
#endif